package net.swa.dewei.web.action;

import javax.annotation.Resource;
import org.springframework.beans.factory.annotation.Required;
import net.swa.dewei.beans.entity.CheXing;
import net.swa.dewei.service.CheXingService;
import net.swa.system.service.ICommonService;
import net.swa.system.util.annotation.Log;
import net.swa.system.web.action.AbstractBaseAction;
import net.swa.util.DateUtils;

/** 车型信息维护 Action **/
public class CheXingAction extends AbstractBaseAction
{
    private static final long serialVersionUID = 3791594428014981760L;

    private CheXingService cheXingService;

    private CheXing model;

    // 实体类id
    private Long id;

    // 批量删除的id集合
    private Long[] ids;

    /** 公用方法接口 */
    private ICommonService commonService;

    @Required
    @Resource
    public void setCommonService(ICommonService commonService)
    {
        this.commonService = commonService;
    }

    public Long getId()
    {

        return id;
    }

    public void setId(Long id)
    {
        this.id = id;
    }

    public Long[] getIds()
    {
        return ids;
    }

    public void setIds(Long[] ids)
    {
        this.ids = ids;
    }

    public CheXing getModel()
    {
        return model;
    }

    public void setModel(CheXing model)
    {
        this.model = model;
    }

    @Required
    @Resource
    public void setCheXingService(CheXingService cheXingService)
    {
        this.cheXingService = cheXingService;
    }

    /** 初始化分页查询 **/
    @Log(description = "初始化车型分页查询")
    public String listPage()
    {
        return "listPage";
    }

    /** 去新增或者修改页面 **/
    @Log(description = "去新增或者修改车型页面")
    public String toAddCheXing() throws Exception
    {
        if (null != id)
        {
            model = commonService.commonFind(CheXing.class, id);
        }
        else
        {
            model = new CheXing();
        }
        return "toAddCheXing";
    }

    /** 新增或者修改 **/
    @Log(description = "新增或者修改车型")
    public String saveCheXing() throws Exception
    {
        if (null == model.getId())
        {
            model.setCrateDate(DateUtils.getCurrDate(null));
            commonService.commonAdd(model);
        }
        else
        {
            model.setUpdateDate(DateUtils.getCurrDate(null));
            commonService.commonUpdate(model);
        }
        outSuccess();
        return null;
    }

    /** * 删除方法 **/
    @Log(description = "删除车型")
    public String delete() throws Exception
    {
        cheXingService.delete(ids);
        outSuccess();
        return null;
    }

    public ICommonService getCommonService()
    {
        return commonService;
    }

}
